﻿namespace EyeOpen.Trial.Windows
{
	using System.Windows.Forms;

	using EyeOpen.Trial.Windows.Properties;

	public partial class RegisterForm : Form
	{
		public RegisterForm()
		{
			this.InitializeComponent();
		}

		public RegisterForm(bool invalidSerialOrExpired)
			: this()
		{
			messageLabel.Visible = invalidSerialOrExpired;
		}

		private void VerifyLinkLabelLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			using (var proxy = new ProxyBuilder().Get())
			{
				var serial = this.serialTextBox.Text;

				if (!proxy.IsValid(serial))
				{
					messageLabel.Visible = true;
					return;
				}

				Settings.Default.Serial = serial;
				Settings.Default.Save();

				this.Visible = false;
				new MainForm().Show(this);
			}
		}    
	}
}